Skip to content

fix(fleet-queue): type-check packet string fields and list elements (#6430) - #8477

Merged
dezren39 merged 2 commits into
mainfrom
queue/10881-6430-packet-string-types
Nov 11, 2026
Merged

dezren39 merged 2 commits into
mainfrom
queue/10881-6430-packet-string-types

Conversation

@dezren39

@dezren39 dezren39 commented Nov 11, 2026 •

Copy link
Copy Markdown
Member

Closes #6430 (fix implemented in the triage claim, per #8187 inline rule — task 10881).

What

validate_packet / manual_schema_errors in pkgs/fleet/crates/fleet-queue/src/validate.rs now type-check the packet's string fields and string-list elements, all as errors naming the field, with no coercion (matching the existing title/prs precedent):

  • top-level packet.body: a present body must be a non-empty string (12345 / {x:1} / [a] / true / "" all error; absent stays allowed)
  • payload.problem, payload.priority_reason: must be non-empty strings
  • payload.dedupe.checked_at, payload.dedupe.basis: must be non-empty strings
  • every element of payload.evidence, acceptance, tests, context_refs must be a string
  • every element of payload.scope.include / scope.exclude must be a string, and scope.exclude must actually be a (non-empty) list
  • every element of payload.risk.flags must be a string

The now-unused is_empty helper is removed.

Tests

  • New unit test packet_string_fields_and_list_elements_are_type_checked pins the valid control (errors=[]) plus 21 malformed variants mapped to the issue's 19 probe cases (body x5, problem x2, priority_reason, dedupe x2, evidence x4, acceptance, tests, context_refs, scope.include, scope.exclude x2, risk.flags) — each must error naming its field.
  • cargo test -p fleet-queue --features queue-broker validate::: 6/6 pass (including the new test).
  • Full suite cargo test -p fleet-queue --features queue-broker: 185 passed, 1 failed — the failure is client::tests::marker_search_is_a_get_and_finds_the_landed_marker, unrelated to this change; it passes on rerun (twice), the same spawn flake recorded for task 14807. Default-feature suite: 30/30 pass.

Corpus re-check

The new rules were checked against the real packet corpus before merge: 1,288 live queue tasks (queued/parked/blocked/claimed/done/handed_off, rich list) — zero violations in any checked field, so no real packet stops validating.

Oracle: the field/element set and error-vs-coerce decision are exactly the acceptance set recorded in the triage verdict on #6430.


Autofix with [code]smith
Open in [code]smith · Need help on this PR? Tag @codesmith-bot with what you need.

…6430)

validate_packet/manual_schema_errors now reject non-string packet.body, payload problem/priority_reason, dedupe.checked_at/basis, and non-string elements of evidence/acceptance/tests/context_refs/scope.include/scope.exclude/risk.flags, each error naming its field; no coercion, matching the title/prs precedent. Pins the #6430 probe cases plus a valid control in validate.rs tests. Corpus re-check: 1288 live queue tasks, zero violations.
@dezren39
dezren39 requested a review from a team as a code owner November 11, 2026 02:59
@coderabbitai

coderabbitai Bot commented Nov 11, 2026 •

Copy link
Copy Markdown

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 37 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 6402ba56-9813-4264-af2e-18c4cdcffa06
Commits

Reviewing files that changed from the base of the PR and between 5981a3f and 4d9a1db.

Files selected for processing: 2

  • pkgs/fleet/crates/fleet-queue/src/turso_queue.rs
  • pkgs/fleet/crates/fleet-queue/src/validate.rs
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 11, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-11T03:07:48.593881Z 4d9a1db Manual request
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 7180d2436f

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +555 to +556
Some(_) => errors.push("packet.body: must be a non-empty string".to_string()),
None => {}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Preserve optional bodies when validating stored task rows

When a valid packet omits the optional body, enqueue still succeeds, but task_from_packet converts the missing field to body: null, which verb_enqueue persists as SQL NULL. The Turso claim path then passes the stored row through claim_guard_reason and validate_packet, where this new branch rejects that null and quarantines the task as blocked. Consequently, accepted body-less tasks can never reach a worker, and existing NULL-body tasks are also affected. Allow the stored representation of an absent body, or normalize it before claim-time validation.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in the follow-up commit — thanks, this was a real catch.

validate_packet now treats body: null exactly like an absent body: null is the stored spelling (task_from_packet writes SQL NULL for a body-less packet, and the #5444 claim guard revalidates stored rows through this same function), so it must not quarantine a task enqueue accepted. Non-string bodies (12345 / {x:1} / [a] / true) and body: '' still error naming packet.body at enqueue.

Regression pins added:

  • validate.rs test: absent-body and null-body packets both validate clean, alongside the malformed cases.
  • turso_queue.rs test: claim_guard_accepts_a_body_less_stored_row — a stored row with body: null (and one with no body key) passes claim_guard_reason.

Verified: cargo test -p fleet-queue --features queue-broker validate:: 6/6, claim_guard 4/4.

…ex P1, #6430)

validate_packet is also the claim guard's oracle (#5444): task_from_packet stores an absent body as SQL NULL, so body:null must validate or body-less tasks quarantine at claim. Adds claim_guard + validator regression pins.
@dezren39

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Keep it up!

Reviewed commit: 4d9a1db4c9

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant